﻿using System;
using Audit.Core.ConfigurationApi;

namespace Shared.Service.Logging.Serilog
{
    public static class SerilogConfiguratorExtensions
    {
        public static ICreationPolicyConfigurator UseSerilog(this IConfigurator configurator, Action<ISerilogConfigurator> config, string appName)
        {
            var serilogConfig = new SerilogConfigurator();
            config.Invoke(serilogConfig);
            Audit.Core.Configuration.DataProvider = new SerilogProvider(appName)
            {
                LogLevelBuilder = serilogConfig.LogLevelBuilder,
                LoggerBuilder = serilogConfig.LoggerBuilder,
                LogMessageBuilder = serilogConfig.MessageBuilder
            };
            return new CreationPolicyConfigurator();
        }
    }
}
